﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAsVu1a2Gd374OJVBz5A7LSxQKG8KDqdzejQUisn9kEvLnCjgoXxQXWBVxIqBzrZjD0pbgvbveRVERqw" type="text/javascript"></script>


	<script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0" type="text/javascript"></script>

    <script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js" type="text/javascript"></script>  


    <style type="text/css">
      @import url("http://www.google.com/uds/css/gsearch.css");
      @import url("http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
      

		.display{font-size:12px}

    </style>
    <script type="text/javascript">
        function load() {
            if (GBrowserIsCompatible()) {
                var px = 30.593086;
                var py = 114.30536;
                var cx = px;
                var cy = py;
                var zoom = 12;
                var map = new GMap2(document.getElementById("map"));
                var point = new GLatLng(px, py);
                map.setCenter(point,zoom);


				//map.setUIToDefault();
				//map.addControl(new GSmallMapControl());

				//map.addControl(new GLargeMapControl());
				//混合地图
				//map.addControl(new GMapTypeControl());

				map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));

				var marker = new google.maps.Marker({
					position: point,
					map: map,
					title:"Hello World!"
				}); 
            }
            /**//*
            获得当前点击的地理坐标
            */
            GEvent.addListener(map, "click", function(marker, point) {
				if (point) {
					px = point.lat();
					py = point.lng();
					zoom = map.getZoom();

					document.getElementById("clickLatNlng").value = px;
					document.getElementById("clickLatNlng").value += ",";
					document.getElementById("clickLatNlng").value += py;

					document.getElementById("clickLat").value = px;
					document.getElementById("clickLng").value = py;


					select("click");
				}
            });
            /**//*
            zoomend地图到达新的缩放级别时会触发此事件。事件处理程序接收先前的缩放级别和新缩放级别作为参数。
            */
            GEvent.addListener(map, "zoomend", function() {
                zoom = map.getZoom();
                //document.getElementById("zoom").value = zoom;
            });
            /**//*
            moveend结束地图视图的更改时会触发此事件。拖动或放大/缩小都会触发此事件
            */
            GEvent.addListener(map, "moveend", function() {
                var center = map.getCenter();
                cx = center.lat();
                cy = center.lng();

                document.getElementById("clickLatNlng").value = cx;
				document.getElementById("clickLatNlng").value += ",";
				document.getElementById("clickLatNlng").value += cy;
				document.getElementById("clickLat").value = cx;
				document.getElementById("clickLng").value = cy;

                document.getElementById("clickcenterLatNLng").value = cx;
                document.getElementById("clickcenterLatNLng").value += ",";
				document.getElementById("clickcenterLatNLng").value += cy;
				document.getElementById("clickcenterLat").value = cx;
				document.getElementById("clickcenterLng").value = cy;

                document.getElementById("zoom").value = zoom;
            });
				document.getElementById("clickLatNlng").value = cx;
				document.getElementById("clickLatNlng").value += ",";
				document.getElementById("clickLatNlng").value += cy;
				document.getElementById("clickLat").value = cx;
				document.getElementById("clickLng").value = cy;

                document.getElementById("clickcenterLatNLng").value = cx;
                document.getElementById("clickcenterLatNLng").value += ",";
				document.getElementById("clickcenterLatNLng").value += cy;
				document.getElementById("clickcenterLat").value = cx;
				document.getElementById("clickcenterLng").value = cy;

                document.getElementById("zoom").value = zoom;
        }
        window.onload = load;

		function select(id){
			if (!window.confirm('确定选择当前点击处为所在地?')) return;
			//var LNL = document.getElementById(id);
			var point = new Object();
			point.lat = document.getElementById(id+"Lat").value;
			point.lng = document.getElementById(id+"Lng").value;
			//alert(LNL.value);
			//alert(LNL.value.split(",")[0]);
			 window.returnValue = point;
			 window.close();
		}
    </script>
</head>
<body>
    <div class='display'>
    <!--点击坐标：--><input type="hidden" style="width:400px" readonly id="clickLatNlng"/><!--<a href='#' onclick='select("click")'>选定</a><br />-->
	<input type="hidden" value="" id="clickLat" /><input type="hidden" value="" id="clickLng" />
    <!--中心坐标：--><input type="hidden" style="width:400px" readonly id="clickcenterLatNLng"/>
	<!--<a href='#' onclick='select("clickcenter")'>选定</a><br />-->
	<input type="hidden" value="" id="clickcenterLat" /><input type="hidden" value="" id="clickcenterLng" />
    <!--当前倍率：--><input type="hidden" id="zoom" readonly />
    </div> 
    <div style="width:600px; height:500px;" id="map"></div>
	
</body>
</html>